#include <bits/stdc++.h>
#define int long long
using namespace std;
int d[100005],v[100005],a[100005];
int p[100005];
vector<pair<int,int>> qry;
void solve(){
	qry.clear();
	int n,m,l,V; cin>>n>>m>>l>>V;
	for(int i=1;i<=n;i++) cin>>d[i]>>v[i]>>a[i];
	for(int i=1;i<=m;i++) cin>>p[i];
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(a[i]<0){
			if(v[i]>V){
				//t=(v[i]-V)/a[i];
				//s=1/2*a[i]*(v[i]-V)*(v[i]-V)/a[i]/a[i]=1/2(v[i]-V)^2/a[i]
				int edpos=((v[i]-V)*(v[i]+V)-1)/(2*-a[i]);
				edpos=min(edpos+d[i],l);
				//[d[i],edpos]
				// cout<<d[i]<<" "<<edpos<<"\n";
				int fst=lower_bound(p+1,p+m+1,d[i])-p,lst=upper_bound(p+1,p+m+1,edpos)-p-1;
				if(fst>lst) continue;
				cnt++; qry.push_back(make_pair(lst,fst));
			}
			else continue;
		}
		else if(a[i]==0){
			if(v[i]>V){
				int edpos=l;
				int fst=lower_bound(p+1,p+m+1,d[i])-p,lst=upper_bound(p+1,p+m+1,edpos)-p-1;
				if(fst>lst) continue;
				cnt++; qry.push_back(make_pair(lst,fst));
			}
			else continue;
		}
		else{
			if(v[i]>V){
				int edpos=l;
				int fst=lower_bound(p+1,p+m+1,d[i])-p,lst=upper_bound(p+1,p+m+1,edpos)-p-1;
				if(fst>lst) continue;
				cnt++; qry.push_back(make_pair(lst,fst));
			}
			else{
				//s=1/2*a[i]*(v[i]-V)*(v[i]-V)/a[i]/a[i]=1/2(v[i]-V)^2/a[i]
				int stpos=d[i]+((V-v[i])*(v[i]+V))/(2*a[i])+1;
				int edpos=l;
				int fst=lower_bound(p+1,p+m+1,stpos)-p,lst=upper_bound(p+1,p+m+1,edpos)-p-1;
				if(fst>lst) continue;
				cnt++; qry.push_back(make_pair(lst,fst));
			}
		}
	}
	int lpos=0,tot=0;
	if(qry.size()){
		sort(qry.begin(),qry.end());
		for(auto v:qry){
			if(v.second>lpos){
				tot++;
				lpos=v.first;
			}
		}
	}
	cout<<cnt<<" "<<m-tot<<"\n";
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int t; cin>>t;
	while(t--) solve();
	return 0;
}
/*
Notices
1. Multitest: print endl before return
2. Multitest: clear (test random ordered sample)
3. Memory
4. long long / int range
5. corner case (minimum and maximum)
6. non-void return value
7. beizeng shangjie
8. -Wall -Wextra -fsanitize=undefined when testing samples, -O2 when testing speed (do not write O2 in the code)
*/